package cn.dliyy.base.service;

import java.lang.reflect.Field;

import cn.dliyy.warehouse.bean.SItems;
import cn.dliyy.warehouse.bean.SStorage;

public class Functions {

	public boolean transfer(Object source, Object objective) {
		// source.
		Class s = source.getClass();
		Class o = objective.getClass();
		s.getDeclaredFields();
		o.getDeclaredFields();

		source = s.cast(objective);
		objective = s.cast(objective);

		return false;
	}

	public static void main(String[] arg0) {
		Functions f = new Functions();
		SItems titems = new SItems();
		SStorage sstorage = new SStorage();
		titems.setNote("titems");
		sstorage.setNote("sstorage");

		// SStorage s=SStorage.class.cast(titems);
		SItems t = SItems.class.cast(sstorage);// (SItems)sstorage;
		System.out.println(t.getNote());
		try {
			Field[] fields=SItems.class.getFields();
			for(int i=0;i<fields.length;i++){
				System.out.println("--"+i+":"+fields[i].toString());
			}
			System.out.println(SItems.class.getDeclaredField("note"));
		} catch (NoSuchFieldException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SecurityException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		f.transfer(titems, sstorage);

		System.out.println("--sstorage-" + sstorage.getNote());
		System.out.println("--titems---" + titems.getNote());
	}
}
